package com.zc.component.network.udp;

import com.zc.component.network.core.Network;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
import java.net.InetSocketAddress;

/**
 * UDP支持
 *
 * @author zhouhao
 */
public interface UdpSupport extends Network {

    /**
     * 获取网络服务绑定的套接字端口信息
     *
     * @return InetSocketAddress
     */
    @Nullable
    InetSocketAddress getBindAddress();

    /**
     * 发送UDP消息
     *
     * @param message UDP消息
     * @return void
     */
    Mono<Void> publish(UdpMessage message);

    /**
     * 订阅UDP消息
     *
     * @return UDP消息流
     */
    Flux<UdpMessage> subscribe();

}
